﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;


public partial class Users_Login : System.Web.UI.Page, ICallbackEventHandler
{
    protected void Page_PreInit(object sender, EventArgs e)
    {
        Page.Theme = BLL.Common.GetWSThemes();
    }
    string result = "";
    protected void Page_Load(object sender, EventArgs e)
    {
        Page.Title = BasePage.WebTitle;
        if (HttpContext.Current.User.Identity.IsAuthenticated)
        {
            Response.Redirect("../Default.aspx");
        }
    }
    public void RaiseCallbackEvent(string eventArgument)
    {
        BLL.V_CUSTOMER bll_customer = new BLL.V_CUSTOMER();
        try
        {
            string[] temp = eventArgument.Split('|');
            string UserCode = temp[0];//用昵称登录

            string pwd = temp[1];
            result=bll_customer.CustomerExists(UserCode, pwd);
            if (result.Length >1)
            {//登录成功
               //string[] info = result.Split('|');
                UserCode = BasePage.GetValue(0);
                bool save=CheckBox12.Checked==true?true:false;
                System.Web.Security.FormsAuthentication.SetAuthCookie(result, save);
                BLL.V_CUSTOMER customer = new BLL.V_CUSTOMER();
                customer.V_Customer_auto_Up(UserCode);

                Model.SYSPARAM sysparam = new Model.SYSPARAM();
                sysparam = new BLL.SYSPARAM().GetModel("007");
                if(sysparam!=null)
                {
                    if (sysparam.SP_PARAM4 == 0)
                    {
                        if(sysparam.SP_PARAM5>-1)
                        {
                            DateTime temptime = DateTime.Now.AddDays(-sysparam.SP_PARAM5);
                            if (new BLL.Recofull_OrderBL().JudgyJFfengcheng(UserCode, temptime))
                            {
                                //调用webservice进行积分分成                                
                                WEB.ERP.Service erp = new WEB.ERP.Service();
                                string key=ConfigurationManager.AppSettings["CODE"];
                                erp.inergalSend(key, UserCode, temptime);
                            }
                        }
                    }
                }
            }
        }
        catch
        {
            result = "0";
        }
    }
    public string GetCallbackResult()
    {
        return result;
    }
}
